#include <stdio.h>
#include <task.h>

	 task_t t1, t2;

void *pong (void *arg){

	char message[] = "lalalalfiokijjhds";

	int message_size = sizeof (message);
	char *response;
	int response_size ;
	
	task_t client;
	
	task_receive (&response_size, sizeof(int));
	response = (char*) malloc (response_size);
	task_receive (response, response_size);
	printf("%s\n",response);
	free(response);
	//task_cooperate();
	task_send (&t2, &message_size, sizeof(int));
	task_send (&t2, message, message_size);
}


void *ping (void *arg){

	char message[] = "rogerrrrrrrrrrrrrrrr";
	int message_size = sizeof (message);
	char *response;
	int response_size ;
	task_send (&t1, &message_size, sizeof(int));
	task_send (&t1, message, message_size);
	task_receive (&response_size, sizeof(int));
	response = (char*) malloc (response_size);
	task_receive (response, response_size);
	printf("%s\n",response);
	free(response);
}

void * main_task(void* arg){

	task_create(&t1, pong, NULL);
	task_create(&t2, ping, NULL);

	return NULL;
}

